package cn.z2huo.demo.kafka.spring.retry.nonblock.config.cluster1;

import cn.z2huo.demo.kafka.spring.retry.nonblock.properties.KafkaConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaAdmin;

import java.util.Map;

/**
 * <p>
 *
 * @author z2huo
 */
@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties(KafkaConfiguration.class)
public class KafkaAdminConfig {

    private final KafkaConfiguration kafkaConfiguration;

    @Bean("cluster1Admin")
    public KafkaAdmin kafkaAdmin() {
        Map<String, Object> properties = this.kafkaConfiguration.getCluster1().buildAdminProperties(null);
        KafkaAdmin kafkaAdmin = new KafkaAdmin(properties);
        return kafkaAdmin;
    }

}
